package ycj.learn.dubbo;

import org.apache.dubbo.config.*;

public class ConsumerTest {
    public static void main(String[] args) {
        ApplicationConfig application = new ApplicationConfig("consumer");

        ReferenceConfig<IHelloService> service = new ReferenceConfig<>(); // 此实例很重，封装了与注册中心的连接，请自行缓存，否则可能造成内存和连接泄漏
        service.setApplication(application);
        service.setRegistry(Configuration.registryConfig()); // 多个注册中心可以用setRegistries()
        service.setInterface(IHelloService.class);
        service.setProtocol("dubbo");

        IHelloService helloService = service.get();

        System.out.println(helloService.hello("world"));
    }
}
